/*
  spr-sdk: Statistical Pattern Recognition SDK
  Copyright (C) 2010 Marco Ambu

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _PR_PCA_H
#define _PR_PCA_H

#include "util/Real.h"
#include "pr/FeatureSpace.h"
#include "pr/TrainingSet.h"

namespace pr {

class Pca
{
public:
  // number of features, max number of eigenvectors, training set, skip first 3 MSFs?
  Pca(TrainingSet& trainingSet);
//
////  void savestate(char *filename);    // save PCA parameters to file
//  util::Real precision() const { return precision_; }
//  bool excludeFirst3() const { return excludeFirst3_; }

  void computeFeatureSpace();
  void transformTrainingSet();

private:
  void klt(std::size_t& numFeatures, Pattern& mseigval, std::vector<Pattern>& mseigv) const;

private:
  TrainingSet& trainingSet_;
//  util::Real precision_;                // precision used to calculate nfeature
//  bool excludeFirst3_;                  // non zero -> skip first 3 MSFs
  FeatureSpace featureSpace_;
};

} // namespace pr

#endif // _PR_PCA_H
